<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="hidden" th:value="3626e3daf71d44b19ce1782d02e31063" name="userId" id="userId"  />
<input type="hidden" th:value="402881b369fa6a5c0169fa73d5540000" name="activityId" id="activityId"/>
<br/>
选择相片:<input type="file" name="uploadFile" id="photofile" multiple /><br/><!--选择上传图片-->
<input th:value="7cbad104-dfe9-49fb-ac1c-cdb6921ae305" type="text" name="albumId" id="albumId"/><!--选择使用相册-->
<input type="button" value="上传" id="submitFile" />

</body>
<script th:src="@{/webjars/jquery/3.3.1/jquery.js}" type="text/javascript"></script>
<script>
    $(function(){
        var type = 1;
        var AlbumId = "";

            $("#submitFile").click(function(){
                if (type==0) {
                    var userId = $("#userId").val();
                    var activityId = $("#activityId").val();
                    var formData = new FormData();
                    for (var i = 0; i < $("#photofile")[0].files.length; i++) {
                        formData.append("uploadFile", $("#photofile")[0].files[i]);    //生成一对表单属性
                    }
                    $.ajax({
                        url: "/activity/fuckPhotos?activityId=" + activityId + "&userId=" + userId,
                        type: 'POST',
                        data: formData,
                        processData: false,
                        contentType: false,
                        cache: false,
                        timeout: 600000,
                        success: function (dt) {
                            console.log(dt);
                        }
                    });
                }

                if (type==1){
                    var userId = $("#userId").val();
                    var activityId = $("#activityId").val();
                    var albumId = $("#albumId").val();
                    da = {"activityId":activityId,"photoAlbumId":albumId};
                    $.ajax({
                        url: "/activity/usePhotoAlbum",
                        type: 'POST',
                        data: JSON.stringify(da),
                        contentType: 'application/json;charset=utf-8',
                        success: function (dt) {
                            console.log(dt);
                        }
                    })
                }
            });
    });
</script>
</html>